Skip to content

[bugfix] Fix the multi-LoRA issue in Twinkle#24

Merged
Jintao-Huang merged 7 commits intomodelscope:mainfrom
Jintao-Huang:fix_twinkle_multi_lora
Apr 10, 2026
Merged

[bugfix] Fix the multi-LoRA issue in Twinkle#24
Jintao-Huang merged 7 commits intomodelscope:mainfrom
Jintao-Huang:fix_twinkle_multi_lora

Conversation

@Jintao-Huang
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces two main changes to src/mcore_bridge/bridge/gpt_bridge.py. First, it refines the logic for processing PEFT-related state dictionary keys in the _set_module function by adding a check for _adapter_name, ensuring that only keys relevant to the current adapter are processed. Second, it adds a None check for the value v before calling the converter function in export_weights, which improves robustness. There are no review comments to address.

@Jintao-Huang
Copy link
Copy Markdown
Collaborator Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refines the handling of PEFT formats in the GPT bridge by adding specific checks for adapter names in state dict keys and bypassing certain weight transformations when PEFT is active. It also introduces a null check for values during weight export to prevent errors. A review comment suggests improving the robustness of the adapter name replacement logic to prevent accidental corruption of keys where the adapter name might appear as a substring elsewhere in the path.

@Jintao-Huang
Copy link
Copy Markdown
Collaborator Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refines the handling of PEFT (LoRA) state dictionaries by improving key mapping logic, ensuring adapter-specific keys are correctly identified, and standardizing dot-notation replacements. It also skips conv1d.weight reformatting when in PEFT mode and adds a null check during weight export. Feedback suggests extending the filtering logic for modules_to_save keys to the full model export path to avoid including redundant weights from other adapters.

@Jintao-Huang
Copy link
Copy Markdown
Collaborator Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates gpt_bridge.py to refine state dictionary key handling for PEFT/LoRA adapters, implementing more precise substring matching and conditional processing for attention weights. It also adds a null check in the weight export process. The review feedback highlights that the new dot-delimited matching logic may fail for keys located at the root of the state dictionary, potentially leading to incorrect filtering or the unintended inclusion of internal module weights.

@Jintao-Huang
Copy link
Copy Markdown
Collaborator Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the GPT bridge to improve the handling of PEFT adapter weights, specifically focusing on filtering and renaming keys for LoRA and modules-to-save patterns. It also introduces a check to skip conv1d weight processing when using PEFT formats and adds a null check during weight export. The review feedback highlights that the current string replacement logic for adapter names is too broad and could lead to false positives or corrupted keys in multi-adapter scenarios. It is recommended to use more specific patterns for matching and replacing adapter names to ensure robustness.

@Jintao-Huang Jintao-Huang merged commit 95a8a6b into modelscope:main Apr 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants